<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>hello</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>

<h2>北京时间为:${time}</h2>

<input id="username" type="text" placeholder="请输入用户名">
<button onclick="loing()">提交</button>

<a href="${bp}/staff/add?username=luanqibazao">我就是测试一下</a>

<form action="${bp}/staff/staff" method="get">
    <input name="username" type="text" placeholder="请输入用户名">
    <input type="submit" value="提交">
</form>

<table>
    <thead>
    <tr>
        <th style="width: 12%">用户名</th>
        <th style="width: 20%">密码</th>
        <th> 操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${staffs}" var="keyword" varStatus="id">
        <tr>
            <td>${keyword.username}</td>
            <td>${keyword.password}</td>

            <td>
                <button>删除</button>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>


</body>
<script type="text/javascript">

    function loing() {

        alert("谈谈")

        var lastname= $("#lastname").val()
        alert(lastname)
        $.ajax({
            type: "GET",
            url: "${bp}/staff/add",
            data: {username: username},
            // 异步回调
            success: function (result) {
                if (result == 1) {
                    alert("密码正确")
                } else {
                    alert("密码错误")
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status);
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
            }

        });

    }


</script>
</html>
